package com.cj.http;

import com.cj.models.ResultModel;
import com.cj.services.UserLevelService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping(path = "/user")
public class UserLevelForPost {

    @Autowired
    UserLevelService userLevelService;
    @PostMapping("upgrade/{userName:\\w+}")
    public ResultModel upgradeUser(@PathVariable("userName")String uname) throws Exception {
        int ret = this.userLevelService.upgrade2(uname);
        if(ret>0){
            return new ResultModel("success","升级成功");
        }
        return new ResultModel("error","升级失败");
    }

}
